import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { NzCustomColumn } from 'ng-zorro-antd/table';

export enum ComponentType {
  Chart,
  Basic
}

export interface CustomColumn extends NzCustomColumn {
  name: string;
  required?: boolean;
  position?: 'left' | 'right';
}

export interface WidgetConfig {
  [key: string]: any;
  field: string;
  status: number;
  title: string;
  minWidth: number;
  minHeight: number;
  defaultWidth: number;
  defaultHeight: number;
  maxWidth: number;
  maxHeight: number;
  tag: string;
  data: NzSafeAny;
  layout?: LayoutPosition;
  configuration?: NzSafeAny;
  imgPath?: string;
  widgetType?: string;
  type: ComponentType;
  value?: string;
  fontSize?: number;
  fontFamily?: string;
}

export interface WidgetSetting {
  field?: string;
  layout?: LayoutPosition;
  settingDate?: Date;
  dashboardBackground: string;
  uniqueKey?: string;
  widgetType?: string;
  freeViewContainer?: HTMLElement;
  isReadMode?: boolean;
  element?: HTMLElement;
  parent?: NzSafeAny;
  guid?: string;
}

export interface LayoutPosition {
  left: string;
  top: string;
  width: string;
  height: string;
}

export interface RectanglePosition {
  left: number;
  top: number;
  width: number;
  height: number;
}

export interface WidgetType {
  type: ComponentType;
  icon: string;
  name: string;
}

const widgetConfigJson: WidgetConfig[] = [
  {
    field: 'line-text',
    status: 0,
    title: '渐变文本',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 120,
    defaultHeight: 50,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'line-text',
    data: null,
    imgPath: 'imgs/lineText.png',
    widgetType: 'line-text',
    type: ComponentType.Basic,
    value: '渐变文本',
    fontSize: 24,
    fontFamily: '黑体',
    direction: '水平方向',
    fontWeight: 300,
    contentMargin: 0,
    upColor: 'rgb(224, 43, 43)',
    backColor: 'rgb(245, 166, 35)',
    letterSpacing: 0,
    backgroundRadius: 0
  },
  {
    field: 'text',
    status: 0,
    title: '文本组件',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 120,
    defaultHeight: 50,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'text',
    data: null,
    imgPath: 'imgs/text.png',
    widgetType: 'line-text',
    type: ComponentType.Basic,
    value: '渐变文本',
    fontSize: 24,
    fontFamily: '黑体',
    upColor: 'rgb(224, 43, 43)'
  },
  {
    field: 'table',
    status: 0,
    title: '表格组件',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 400,
    defaultHeight: 150,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'table',
    data: null,
    imgPath: 'imgs/table.png',
    widgetType: 'table',
    type: ComponentType.Basic,
    value: '表格组件',
    fontSize: 24,
    fontFamily: '黑体'
  },
  {
    field: 'serial-chart',
    status: 0,
    title: '柱状图',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 225,
    defaultHeight: 155,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'serial-chart',
    data: null,
    imgPath: 'imgs/serial-chart.png',
    widgetType: 'serial-chart',
    type: ComponentType.Chart
  },
  {
    field: 'area-chart',
    status: 0,
    title: '面积图',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 225,
    defaultHeight: 155,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'area-chart',
    data: null,
    imgPath: 'imgs/area-chart.png',
    widgetType: 'area-chart',
    type: ComponentType.Chart
  },
  {
    field: 'pie-chart',
    status: 0,
    title: '饼图',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 225,
    defaultHeight: 155,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'pie-chart',
    data: null,
    imgPath: 'imgs/pie-chart.png',
    widgetType: 'pie-chart',
    type: ComponentType.Chart
  },
  {
    field: 'loudou-chart',
    status: 0,
    title: '漏斗图',
    minWidth: 56,
    minHeight: 33,
    defaultWidth: 225,
    defaultHeight: 155,
    maxWidth: 545,
    maxHeight: 375,
    tag: 'loudou-chart',
    data: null,
    imgPath: 'imgs/loudou-chart.png',
    widgetType: 'loudou-chart',
    type: ComponentType.Chart
  }
];

const widgetType: WidgetType[] = [
  { type: ComponentType.Basic, icon: 'highlight', name: '基础' },
  { type: ComponentType.Chart, icon: 'pie-chart', name: '图表' }
];

export default { widgetConfigJson, widgetType };
